package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmPageReqDto;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.wemedia.service.WmChannelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/api/v1/channel")
public class WmchannelController {

    @Autowired
    private WmChannelService wmChannelService;

//    @GetMapping("/channels")
//    public ResponseResult findAll() {
//        return wmChannelService.findAll();
//    }

    @PostMapping("/list")
    public ResponseResult list(@RequestBody WmPageReqDto dto) {
        log.info("频道列表查询: {}", dto);
        return wmChannelService.findChannelList(dto);
    }

    @PostMapping("/save")
    public ResponseResult saveChannel(@RequestBody WmChannel wmChannel) {
        log.info("保存频道;{}", wmChannel);
        return wmChannelService.saveChannel(wmChannel);
    }

    @GetMapping("/del/{id}")
    public ResponseResult delChannel(@PathVariable("id") Integer id) {
        log.info("删除频道: {}", id);
        return wmChannelService.delChannel(id);
    }

    @PostMapping("/update")
    public ResponseResult upChannel(@RequestBody WmChannel wmChannel) {
        log.info("修改频道;{}", wmChannel);
        return wmChannelService.upChannel(wmChannel);
    }
}